<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_order_send_logs}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_id
 * @property string $b_code
 * @property string $to_api_data
 * @property string $ed_data
 * @property string $to_ed_data
 * @property string $ed_resp_code
 * @property string $ed_resp_data
 * @property int $created_at
 *
 * @property EdiviCreditOrder $ediviCreditOrder
 */
class EdiviOrderSendLogs extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_order_send_logs}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_id', 'b_code', 'to_api_data', 'ed_data', 'to_ed_data', 'created_at'], 'required'],
            [['edivi_credit_order_id', 'created_at'], 'integer'],
            [['to_api_data', 'ed_data', 'to_ed_data', 'ed_resp_code', 'ed_resp_data'], 'string'],
            [['b_code'], 'string', 'max' => 4],
            [['edivi_credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_credit_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_id' => Yii::t('app', 'Edivi Credit Order ID'),
            'b_code' => Yii::t('app', 'B Code'),
            'to_api_data' => Yii::t('app', 'To Api Data'),
            'ed_data' => Yii::t('app', 'Ed Data'),
            'to_ed_data' => Yii::t('app', 'To Ed Data'),
            'ed_resp_code' => Yii::t('app', 'Ed Resp Code'),
            'ed_resp_data' => Yii::t('app', 'Ed Resp Data'),
            'created_at' => Yii::t('app', 'Created At'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_credit_order_id']);
    }
}
